package com.qiyuexinxi.chat.controller;

import com.qiyuexinxi.chat.common.GenericResponse;
import com.qiyuexinxi.chat.constants.api.ThumbInfoApi;
import com.qiyuexinxi.chat.dto.request.AddThumbInfoRequest;
import com.qiyuexinxi.chat.dto.request.ThumbInfoListRequest;
import com.qiyuexinxi.chat.service.impl.ThumbInfoServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * @author yangxingyu
 * @date 2020/3/24
 * @description
 */
@RestController
@Api(description = "点赞相关接口")
public class ThumbInfoController {

    @Autowired
    ThumbInfoServiceImpl thumbInfoService;

    @PostMapping(value = ThumbInfoApi.ADD_THUMBINFO, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "增加点赞", notes = "增加点赞")
    public GenericResponse addThumbInfo(@Valid @RequestBody AddThumbInfoRequest addThumbInfoRequest){
        return new GenericResponse(thumbInfoService.addThumbInfo(addThumbInfoRequest));
    }

    @PostMapping(value = ThumbInfoApi.DELETED_THUMBINFO, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "取消点赞", notes = "取消点赞")
    public GenericResponse deletedThumbInfo(@Valid @RequestBody AddThumbInfoRequest addThumbInfoRequest){
        return new GenericResponse(thumbInfoService.deletedThumbInfo(addThumbInfoRequest));
    }

    @PostMapping(value = ThumbInfoApi.LIST_THUMBINFO, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "获取点赞列表", notes = "获取点赞列表")
    public GenericResponse getThumbInfoList(@Valid @RequestBody ThumbInfoListRequest thumbInfoListRequest){
        return new GenericResponse(thumbInfoService.getThumbInfoList(thumbInfoListRequest));
    }

    @PostMapping(value = ThumbInfoApi.THUMBINFO_COUNT, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "获取点赞数量", notes = "获取点赞数量")
    public GenericResponse getThumbInfoCount(@Valid @RequestBody ThumbInfoListRequest thumbInfoListRequest){
        return new GenericResponse(thumbInfoService.getThumbInfoCount(thumbInfoListRequest));
    }


}
